//
//  GGToolsMainVC.m
//  qqqqqq
//
//  Created by iOSer on 2017/3/15.
//  Copyright © 2017年 iOSer. All rights reserved.
//

#import "GGToolsMainVC.h"

@interface GGToolsMainVC ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong) UITableView *tableView;
@property(nonatomic,strong) NSMutableArray *dataSourceArrayM;
@end

@implementation GGToolsMainVC

- (void)viewDidLoad {
    [super viewDidLoad];
     self.dataSourceArrayM = [[NSMutableArray alloc] initWithArray:@[@"打卡"]];
}


-(void)viewWillAppear:(BOOL)animated{
    [self setupUI];
}

-(void)setupUI{
    
    [self.view addSubview:self.tableView];
    
    
    [_tableView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.left.right.bottom.equalTo(self.view);
    }];
    
}
#pragma mark - tableView
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dataSourceArrayM.count + 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [UITableViewCell new];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.row<self.dataSourceArrayM.count) {
        cell.textLabel.text = [NSString stringWithFormat:@"%ld.     %@",(long)indexPath.row,self.dataSourceArrayM[indexPath.row]];
    }else{
        cell.textLabel.text = [NSString stringWithFormat:@"%ld.     暂无",(long)indexPath.row];
    }
    //完全取消cell的选中状态
    //    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    //修改cell选中颜色
    cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
    cell.selectedBackgroundView.backgroundColor = HEXColor(0xf5f5f5, 1);
    return cell;
}


//cell的点击事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    //取消cell选中状态,按下变灰
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    if (indexPath.row == 0) {
        [[GGRoute shareGGRouterInstance] handleURL:[NSURL URLWithString:@"GG://com.ggroute.demo/toolsSignin"] primitiveParameters:nil isJumpMothod:PUSH isShowNav:YES NAVTitle:@"打卡签到" isNavAnimation:YES targetCallBack:^(NSError *error, id responseObject) {
            NSLog(@"回调");
        } withCompletionBlock:^(BOOL handled, NSError *error) {
            
        }];
    }
}
//懒加载
-(UITableView *)tableView{
    if (!_tableView) {
        
        
        //        [_tableView setContentOffset:CGPointMake(0,200) animated:NO];
        _tableView = [[UITableView alloc] init];
        //设置数据源
        _tableView.delegate = self;
        _tableView.dataSource = self;
        //取消下划线
        _tableView.separatorStyle = UITableViewCellSelectionStyleNone;
        //隐藏滚动条
        _tableView.showsVerticalScrollIndicator = NO;
        [_tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
    }
    
    return _tableView;
}




@end
